package com.sos.data.adapters
{
	import com.sos.DebugOptions;

	public class DebugOptionsAdapter
	{

		public static function fromXML(xml:XML):DebugOptions
		{
			// Create new configurtion
			var options:DebugOptions = new DebugOptions();
			// Safe exec
			try
			{
				// Properties
				options.enabled 		= Boolean(xml.enabled == "1");
				options.userID 			= xml.user.id;
				options.userUsername 	= xml.user.username;
				options.userPassword 	= xml.user.password;
				// Keys
				for each (var key:XML in xml.keys.key)
				{
					options.keys.push(key);
				}
			}
			// Unexpected exception
			catch (e:Error)
			{
				throw new Error("DebugOptionsAdapter.fromXML() unexpected error: " + e.toString());
			}
			return options;
		}
		
	}
}